package muti;

/**
 * 线程中断标记不能作为线程停止标记Demo
 */
public class MayNotBeTerminatedDemo {
    public static void main(String[] args) throws InterruptedException {
        TaskRunner tr = new TaskRunner();
        tr.init();
        tr.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("before doing task");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    //什么也不做：这会导致线程中断标记被清除
                }
                System.out.println("after doing task");
            }
        });
        tr.workerThread.interrupt();
    }
}
